package com.red.star.macalline.data.mappers;

import com.red.star.macalline.data.core.base.MyMapper;
import com.red.star.macalline.data.entity.FansCard;
import com.red.star.macalline.data.entity.vo.FansCardPojo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

/**
 * @author AMGuo
 * @Description 粉丝蓄客卡
 * @date 2018/03/02 10:48
 */
public interface FansCardMapper extends MyMapper<FansCard> {

	public FansCard findByCondition(@Param("cardId") Integer cardId, @Param("groupId") Integer groupId,
	                                @Param("employeeId") Integer employeeId, @Param("unionId") String unionId);

	@Select(value = "select * from t_fans_card t where t.union_id is not null")
	public List<FansCard> findByNotNullUnionId();

	@Select(value = "select count(t.card_id) from t_fans_card t where t.card_id = #{cardId} and" +
			" t.pay_status = #{status} and t.union_id = #{unionId}")
	public Integer findByStatus(@Param("cardId") Integer cardId, @Param("status") Integer status,
	                            @Param("unionId") String unionId);

	Integer countByUnionId(@Param("unionId") String unionId, @Param("nowDate") Date nowDate,
	                       @Param("omsCode") String omsCode);

	List<FansCard> findByUnionId(@Param("unionId") String unionId, @Param("nowDate") Date nowDate,
	                             @Param("omsCode") String omsCode);

	public List<FansCardPojo> getAllFansCardList(FansCardPojo fansCardPojo);

	public List<FansCard> queryStoredCardByFansCard(@Param("id") Integer id);
}
